package com.cg.test;

/**
 * @author cheyinbo
 * @description 无锁无threadLocal
 * @date 2021/8/4 9:47
 */
public class ThreadLocalDemo1 {

    private String content;

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public static void main(String[] args) {
        ThreadLocalDemo1 threadLocalDemo1 = new ThreadLocalDemo1();
        for (int i = 0; i < 5; i++) {
            Thread thread = new Thread(() -> {
                threadLocalDemo1.setContent(Thread.currentThread().getName() + "的数据");
                System.out.println(Thread.currentThread().getName() + "->" + threadLocalDemo1.getContent());
            });
            thread.setName("线程" + i);
            thread.start();
        }
    }

}
